package com.blog.backend.controller;

import com.blog.backend.annotation.LoginAnno;
import com.blog.backend.model.BlogPlate;
import com.blog.backend.req.InsertPlateReq;
import com.blog.backend.req.TagReq;
import com.blog.backend.resp.ClassifyResp;
import com.blog.backend.resp.TagResp;
import com.blog.backend.service.ClassifyTagService;
import com.blog.backend.service.PlateService;
import com.blog.backend.utils.Result;
import com.blog.backend.vo.PageRequest;
import com.blog.backend.vo.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api("文章分类和标签处理接口")
public class ClassifyTagController {

    @Autowired
    private ClassifyTagService classifyTagService;

    @Autowired
    private PlateService plateService;

    @GetMapping("/tag/selectTags")
    @ApiOperation("查询标签列表")
    @LoginAnno
    public Result<List<TagResp>> selectTagList(@RequestParam("classifyId") String classifyId){
        List<TagResp> list= classifyTagService.selectTagList(classifyId);
        return Result.success(list);
    }

    @GetMapping("/classify/selectClassifyList")
    @ApiOperation("查询分类明细列表")
    @LoginAnno
    public Result<List<ClassifyResp>> selectClassifyList(@RequestParam("type") String type){
        List<ClassifyResp> list = classifyTagService.selectClassifyList(type);
        return Result.success(list);
    }

    @PostMapping("/tag/insertTags")
    @LoginAnno
    @ApiOperation("新增标签")
    public Result<Boolean> insertTag(@RequestBody TagReq tagReq){
        Boolean result=classifyTagService.insertTag(tagReq);
        return Result.success(result);
    }

    @PostMapping("tag/selectPageTags")
    @LoginAnno
    @ApiOperation("查看标签列表分页")
    public Result<PageResult> selectPageTags(@RequestBody PageRequest request){
        PageResult list = classifyTagService.selectPageTags(request);
        return Result.success(list);
    }

}
